const Qs = require('qs');

let treeListItem = {
    'line|1-10': 2,
    'trains|10': [
        /\d{5,10}/,
    ]
};

let trainListItem = {
        value: "GZML18",
        label: "GZML18",
        'children|10' : [{
            value: 18001002,
            label: 18001002,
        }],
};

let diagram = {
    "sceneCode": 1,
    "sceneName": "紧急制动无法缓解",
    "system": "制动系统",
    "systemCode": "BCU",
    "images": [
    {
        "imageName": "紧急制动无法缓解",
        "nodes": [
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 0,
                "row": 0,
                "column": 0,
                "type": 0,
                "text_content": "手动：停放制动缓解灯不亮",
                "text_color": null,
                "status": 'TRUE' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 1,
                "row": 1,
                "column": 0,
                "type": 1,
                "text_content": "自动：停放制动图标是否处于缓解状态",
                "text_color": null,
                "status": 'TRUE' ,
                "var": "isBCURelieve"
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 2,
                "row": 2,
                "column": 0,
                "type": 0,
                "text_content": "手动：停放制动图标处于施加状态",
                "text_color": null,
                "status": 'TRUE' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 3,
                "row": 3,
                "column": 0,
                "type": 1,
                "text_content": "自动：停放制动开关（28-F103）是否跳闸",
                "text_color": null,
                "status": 'STOP' ,
                "var": "isBCUSwitchOff"
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 4,
                "row": 5,
                "column": 0,
                "type": 0,
                "text_content": "手动：操作停放制动旁路开关（=27-S103）",
                "text_color": null,
                "status": 'STOP' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 5,
                "row": 6,
                "column": 0,
                "type": 1,
                "text_content": "手动：能否动车",
                "text_color": null,
                "status": 'TRUE' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 6,
                "row": 7,
                "column": 0,
                "type": 0,
                "text_content": "手动：操作保底措施",
                "text_color": null,
                "status": 'STOP' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 7,
                "row": 8,
                "column": 0,
                "type": 1,
                "text_content": "手动：能否动车",
                "text_color": null,
                "status": 'STOP' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 8,
                "row": 9,
                "column": 0,
                "type": 2,
                "text_content": "申请救援",
                "text_color": null,
                "status": 'TRUE' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 9,
                "row": 3,
                "column": 1,
                "type": 0,
                "text_content": "手动：恢复停放制动开关（28-F103)",
                "text_color": null,
                "status": 'STOP' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 10,
                "row": 4,
                "column": 1,
                "type": 1,
                "text_content": "自动：停放制动图标是否处于缓解状态",
                "text_color": null,
                "status": 'STOP' ,
                "var": "isBCURelieve"
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 11,
                "row": 5,
                "column": 1,
                "type": 0,
                "text_content": "手动：操作停放制动旁路开关（=27-S103）",
                "text_color": null,
                "status": 'TRUE' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 12,
                "row": 6,
                "column": 1,
                "type": 2,
                "text_content": "运行至下一站清客后，驾驶到就近车线退出服务",
                "text_color": null,
                "status": 'STOP' ,
                "var": null
            },
            {
                "diagramId": 0,
                "system": "制动系统",
                "nodeId": 13,
                "row": 5,
                "column": 2,
                "type": 2,
                "text_content": "继续运行到终点站退出服务",
                "text_color": null,
                "status": 'STOP' ,
                "var": null
            }
        ],
        "edges": [
            {
                "edgeId": 0,
                "diagramId": 0,
                "nodeId": 0,
                "target": 1,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": null,
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 1,
                "diagramId": 0,
                "nodeId": 1,
                "target": 2,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": "N",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 2,
                "diagramId": 0,
                "nodeId": 1,
                "target": 13,
                "startConnector": 3,
                "endConnector": 2,
                "text_content": "Y",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 3,
                "diagramId": 0,
                "nodeId": 2,
                "target": 3,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": null,
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 4,
                "diagramId": 0,
                "nodeId": 3,
                "target": 4,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": "N",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 5,
                "diagramId": 0,
                "nodeId": 3,
                "target": 9,
                "startConnector": 3,
                "endConnector": 1,
                "text_content": "Y",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 6,
                "diagramId": 0,
                "nodeId": 4,
                "target": 5,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": null,
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 7,
                "diagramId": 0,
                "nodeId": 5,
                "target": 6,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": "N",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 8,
                "diagramId": 0,
                "nodeId": 5,
                "target": 12,
                "startConnector": 3,
                "endConnector": 1,
                "text_content": "Y",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 9,
                "diagramId": 0,
                "nodeId": 6,
                "target": 7,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": null,
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 10,
                "diagramId": 0,
                "nodeId": 7,
                "target": 8,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": "N",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 11,
                "diagramId": 0,
                "nodeId": 7,
                "target": 12,
                "startConnector": 3,
                "endConnector": 4,
                "text_content": "Y",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 12,
                "diagramId": 0,
                "nodeId": 9,
                "target": 10,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": null,
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 13,
                "diagramId": 0,
                "nodeId": 10,
                "target": 4,
                "startConnector": 1,
                "endConnector": 2,
                "text_content": "N",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 14,
                "diagramId": 0,
                "nodeId": 10,
                "target": 11,
                "startConnector": 4,
                "endConnector": 2,
                "text_content": "Y",
                "text_color": null,
                "color": null
            },
            {
                "edgeId": 15,
                "diagramId": 0,
                "nodeId": 11,
                "target": 13,
                "startConnector": 3,
                "endConnector": 1,
                "text_content": null,
                "text_color": null,
                "color": null
            }
        ]
    }
]
}

const getListData = (item) => {

    let TreeListData = [];

    for (let i = 0; i < 10; i++) {
        TreeListData.push(item);
    }
    return TreeListData;
}

// let treeList = getListData(treeListItem);
let trainList = getListData(trainListItem);


export default {
    'get|emergency/emergy_detail':  option => {
        return {
            status: 200,
            message: 'success',
            result: diagram
        };
    },
    'get|emergency/emergy_proccess_detail':  option => {
        return {
            status: 200,
            message: 'success',
            result: diagram
        };
    },
    'get|/emergency/driver_operate':  option => {
        return {
            "success":true,
            "message":"操作成功！",
            "code":200,
            "result":[{
                "operateTime":"12:00:00",
                "operateDescr":"恢复停放制动开关"
            },{
                "operateTime":"11:00:00",
                "operateDescr":"恢复停放制动旁路开关"
            }],
            "timestamp":1621818809912
        };
    },
    'post|/emergency/manual_confirm': option => {
        console.log(Qs.parse(option));
        console.log(option);
    }

}
